#ifndef __IAP_H
#define	__IAP_H

#include <stdint.h>

/* IAP Command Status Codes */
#define IAP_STA_CMD_SUCCESS 								0
#define IAP_STA_INVALID_COMMAND 						1
#define IAP_STA_SRC_ADDR_ERROR 							2
#define IAP_STA_DST_ADDR_ERROR 							3
#define IAP_STA_SRC_ADDR_NOT_MAPPED 				4
#define IAP_STA_DST_ADDR_NOT_MAPPED 				5
#define IAP_STA_COUNT_ERROR 								6
#define IAP_STA_INVALID_SECTOR 							7
#define IAP_STA_SECTOR_NOT_BLANK						8
#define IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 	9
#define IAP_STA_COMPARE_ERROR 							10
#define IAP_STA_BUSY 										    11
#define IAP_STA_INVALD_PARAM 								12

void vIAP_ReinvokeISP(void);
uint32_t u32IAP_ReadPartID(uint32_t *pu32PartID);
uint32_t u32IAP_ReadBootVersion(uint32_t *pu32Major, uint32_t *pu32Minor);
uint32_t u32IAP_EraseSectors(uint32_t u32StartSector, uint32_t u32EndSector);
uint32_t u32IAP_PrepareSectors(uint32_t u32StartSector, uint32_t u32EndSector);
uint32_t u32IAP_CopyRAMToFlash(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len);
uint32_t u32IAP_BlankCheckSectors(uint32_t u32StartSector, uint32_t u32EndSector, uint32_t *pu32Result);
uint32_t u32IAP_Compare(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len, uint32_t *pu32Offset);
void u32IAP_ReadSerialNumber(uint32_t *pu32byte0, uint32_t *pu32byte1, uint32_t *pu32byte2, uint32_t *pu32byte3);

#endif /* end __IAP_H */
